var util = require("../../utils/util.js"),
  api = require("../../utils/api.js"),
  app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageIndex: 1,
    pageSize: 10,
    configDetail:null,
    baseImgUrl: app.globalData.baseImgUrl,
    idCard:'',
    dataList: [],
    active: 0,
    playStatusNum:0,
    showEmpty:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.init()
  },
  init() {
    api.default.config().then(res => {
      let business_other_mobile=[];
      try{
        business_other_mobile=Array.isArray(JSON.parse(res.data.business_other_mobile))?JSON.parse(res.data.business_other_mobile):[]
      }catch(e){};
      res.data.business_other_mobile=business_other_mobile;
      this.setData({configDetail:res.data})
    })
  },
  telphone(e){
    let phone = e.currentTarget.dataset.phone;
    wx.makePhoneCall({
      phoneNumber: phone
    })
  },
  getidCard(e){
    this.setData({idCard:e.detail.value})
    if(e.detail.value == ''){
      this.setData({showEmpty:false})
    }
  },
  search(){
    let idCard=this.data.idCard;
    if (!idCard || idCard == '') {
      return wx.showToast({
        title: '身份证号码未填写',
        icon: 'none'
      })
    } 
    this.getAppointRecords(); 
  },

  async getAppointRecords() { 
    const {idCard,pageIndex,pageSize}=this.data;
    let parms={
        idcard:idCard,
        page: pageIndex,
        pageSize: pageSize,
        serchtype:'byhand'
    }
    let {data}=await api.default.myInclaimantList(parms);
    let list=Array.isArray(data.list)?data.list:[];
    this.setData({
        dataList: list,
        showEmpty: 0 == list.length
    });
},

toDetail(e) { 
    let id= e.currentTarget.dataset.id; 
    let ordernum = e.currentTarget.dataset.ordernum; 
    wx.navigateTo({
      url: '/pages/mine/myorder/orderdetail?id=' + id+"&ordernum="+ordernum, 
    })
  },


  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})